package com.shqcjd.sinopecdemomobile.ui.adapter;

import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.shqcjd.sinopecdemomobile.R;
import com.shqcjd.sinopecdemomobile.model.pojo.IndexBean;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by sy on 2019/5/7.
 */

public class KnowledgeBaseAdapter extends BaseQuickAdapter<IndexBean.KnowledgeBean,KnowledgeBaseAdapter.ViewHolder> {

    public KnowledgeBaseAdapter() {
        super(R.layout.item_index_knowledge_base);
    }

    @Override
    protected void convert(KnowledgeBaseAdapter.ViewHolder helper, IndexBean.KnowledgeBean item) {
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.ic_default_small)	//加载成功之前占位图
                .error(R.mipmap.ic_default_small)	//加载错误之后的错误图
//                .override(88,87)	//指定图片的尺寸
                .centerCrop();//指定图片的缩放类型为centerCrop （等比例缩放图片，直到图片的宽高都
        Glide.with(mContext)
                .load(item.img+"?x-oss-process=video/snapshot,t_10000,f_jpg,w_800,h_600")
                .apply(options)
                .into(helper.riv_img);

        helper.tv_pos.setText((helper.getAdapterPosition()+1)+"");
        helper.tv_name.setText(item.name);
        helper.tv_info.setText(item.tags);
    }

    class ViewHolder extends BaseViewHolder {
        @BindView(R.id.riv_img)
        RoundedImageView riv_img;
        @BindView(R.id.tv_pos)
        TextView tv_pos;
        @BindView(R.id.tv_name)
        TextView tv_name;
        @BindView(R.id.tv_info)
        TextView tv_info;
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}